package com.danke.banner.demo.ui;

import android.os.Bundle;

import com.danke.banner.demo.R;
import com.danke.banner.demo.adapter.RecyclerBannerAdapter;
import com.danke.banner.demo.entity.RecyclerBannerBean;
import com.danke.banner.demo.entity.RecyclerBaseItemBean;
import com.danke.banner.demo.entity.RecyclerNormalBean;
import com.danke.banner.demo.utils.DataProvider;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

/**
 * @author wupuquan
 * @version 1.0
 * @since 2020/3/26 10:31
 */
public class BannerInRecyclerViewActivity extends AppCompatActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_recyclerview);

        RecyclerView recyclerView = findViewById(R.id.recyclerView);
        recyclerView.setLayoutManager(new LinearLayoutManager(this));

        List<RecyclerBaseItemBean> list = new ArrayList<>();
        for (int i = 0; i < 3; i++) {
            RecyclerNormalBean normalBean = new RecyclerNormalBean("第 " + i + "项");
            list.add(normalBean);
        }
        //banner
        list.add(new RecyclerBannerBean(Arrays.asList(DataProvider.urls)));
        for (int i = 3; i < 23; i++) {
            RecyclerNormalBean normalBean = new RecyclerNormalBean("第 " + i + "项");
            list.add(normalBean);
        }
        //banner
        list.add(new RecyclerBannerBean(Arrays.asList(DataProvider.urls)));
        RecyclerBannerAdapter adapter = new RecyclerBannerAdapter(list);
        recyclerView.setAdapter(adapter);
    }
}
